home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / apps / 630 / doc / gs241.bug < prev    next >
Text File  |  1992-05-05  |  4KB  |  122 lines

  1. There follows a patch to gdevgif.c that fixes the problem when used on
  2. "big endian" machines (e.g. Suns). The image dimensions are stored as short
  3. ints in LSB order in GIF files, so on big endian machines the bytes that
  4. make up the shorts need to be swapped. The patch also fixes the
  5. "redeclaration of gif_print_page" error given by some compilers.
  6.  
  7. James Pearson
  8. +------------------------------------------------------------------------+
  9. Dept. Photogrammetry & Surveying     INTERNET: j.pearson@ps.ucl.ac.uk
  10. University College London                UUCP: ...!uknet!cs.ucl!jcpearso
  11. Gower Street                            JANET: j.pearson@uk.ac.ucl.ps
  12. London  WC1E 6BT
  13. England
  14.  
  15.  
  16.  
  17. *** gdevgif.c.orig    Sat Apr 25 18:40:51 1992
  18. --- gdevgif.c    Sat Apr 25 18:42:37 1992
  19. ***************
  20. *** 300,308 ****
  21.       }
  22.   }
  23.   
  24.   
  25.   /* Write a page to a file in GIF format. */
  26. ! int
  27.   gif_print_page(gx_device_printer *pdev, FILE *file)
  28.   {    int raster = gdev_prn_bytes_per_scan_line(pdev);
  29.       int height = pdev->height;
  30. --- 300,327 ----
  31.       }
  32.   }
  33.   
  34. + #if arch_is_big_endian
  35. + union scombine{
  36. +     ushort num;
  37. +     uchar bytes[2];
  38. + };
  39. + private void
  40. + sswap(ushort *ival, ushort *oval)
  41. + {
  42. +     union scombine tmp;
  43. +  
  44. +     tmp.num = *ival;
  45. +     /**interchange the bytes**/
  46. +     tmp.bytes[0] ^= tmp.bytes[1];
  47. +     tmp.bytes[1] ^= tmp.bytes[0];
  48. +     tmp.bytes[0] ^= tmp.bytes[1];
  49. +  
  50. +     *oval = tmp.num;
  51. + }
  52. + #endif arch_is_big_endian
  53.   
  54.   /* Write a page to a file in GIF format. */
  55. ! private int
  56.   gif_print_page(gx_device_printer *pdev, FILE *file)
  57.   {    int raster = gdev_prn_bytes_per_scan_line(pdev);
  58.       int height = pdev->height;
  59. ***************
  60. *** 330,335 ****
  61. --- 349,358 ----
  62.                           /* width must be on byte */
  63.                           /* boundry         */
  64.       header.height = height;
  65. + #if arch_is_big_endian
  66. +     sswap(&header.height,&header.height);
  67. +     sswap(&header.width,&header.width);
  68. + #endif 
  69.   /*    header.flags.globalcolor = TRUE;    */
  70.   /*    header.flags.colorres = depth-1;    */
  71.   /*    header.flags.sort = FALSE;        */
  72. ***************
  73. *** 360,365 ****
  74. --- 383,394 ----
  75.       header_desc.top_pos = 0;
  76.       header_desc.width = raster * (8/depth);    /*pdev->width;*/
  77.       header_desc.height = height;
  78. + #if arch_is_big_endian
  79. +     sswap(&header_desc.left_pos,&header_desc.left_pos);
  80. +     sswap(&header_desc.top_pos,&header_desc.top_pos);
  81. +     sswap(&header_desc.width,&header_desc.width);
  82. +     sswap(&header_desc.height,&header_desc.height);
  83. + #endif
  84.   /*    header_desc.flags.localcolor = FALSE;    */
  85.   /*    header_desc.flags.interlace = FALSE;    */
  86.   /*    header_desc.flags.sort = FALSE;        */
  87.  
  88. ----------------------------------------------------------
  89.  
  90. > >thanks for your reply. I tried your suggestion and compiled gs24 without
  91. > >optimization. It didn't change a bit. I then narrowed down the problem
  92. > >to the gs_init.ps script. By adding junk lines I discovered that the
  93. > >problem occurs towards the end of this script at a line consisting of
  94. > >                 scrinit
  95. >   ^^^^^^^
  96. > I'm sorry this should have been "setscreen".
  97.  
  98. There is a bug in the halftone screen logic in Ghostscript 2.4.1 (and
  99. 2.4 also) that may cause it to fail under some conditions for
  100. high-resolution printers.  To fix this, change lines 234-235 of
  101. gxht.c from
  102.  
  103.     if ( num_cached == size && num_cached <= max_cached_tiles / 2 )
  104.        {    /* We can afford to replicate every tile vertically, */
  105.  
  106. to
  107.  
  108.     if ( num_cached == size &&
  109.          tile_bytes * num_cached <= max_ht_bits / 2
  110.        )
  111.        {    /* We can afford to replicate every tile vertically, */
  112.  
  113. Please let me know if this fixes (or doesn't fix) the problem.
  114.  
  115. L. Peter Deutsch :: Aladdin Enterprises :: P.O. box 60264, Palo Alto, CA 94306
  116. ghost@aladdin.com, ...decwrl!aladdin!ghost ; 415-322-0103 8-9 AM M-F/msg
  117.         "Implementation is the sincerest form of flattery."
  118.  
  119.  
  120.